using Game.Main.Model;
using Game.XH;
using SimpleJSON;

namespace Game.Component
{
	public class ClickShowItem : BaseItem
	{
		public enum State
		{
			Hide = 0,
			Show = 1
		}

		protected State state;

		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
			SetState((State)data.state);
		}

		public override void QuicklyTouch(TouchEventData touchEventData)
		{
			base.QuicklyTouch(touchEventData);
			if (state == State.Hide)
			{
				SetState(State.Show);
			}
			else
			{
				SetState(State.Hide);
			}
		}

		public virtual void SetState(State val)
		{
			if (state != val)
			{
				state = val;
				if (state == State.Hide)
				{
					model.Find(base.itemData.scriptParams).SetObjectActive(false);
				}
				else
				{
					model.Find(base.itemData.scriptParams).SetObjectActive(true);
				}
			}
		}

		public override void PackData(JSONObject obj)
		{
			base.PackData(obj);
			obj["33"] = (int)state;
		}
	}
}
